package com.huawei.appmarket.service.subtab.view;

import android.content.Context;
import android.content.Intent;
import android.graphics.Rect;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import androidx.fragment.app.FragmentActivity;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.RecyclerView.f;
import androidx.recyclerview.widget.RecyclerView.s;
import androidx.recyclerview.widget.RecyclerView.t;
import com.huawei.appgallery.foundation.ui.framework.cardframe.fragment.BaseListFragment;
import com.huawei.appgallery.foundation.ui.framework.cardframe.fragment.protocol.BaseListFragmentProtocol;
import com.huawei.appgallery.foundation.ui.framework.widget.BottomButton;
import com.huawei.appgallery.serverreqkit.api.bean.startup.StartupResponse.TabInfo;
import o.azb;
import o.cks;
import o.cku;
import o.dgm;
import o.Logger;
import o.dof;
import o.ContentManager;
import o.ejh;
import o.ejh.c;
import o.eji;
import o.ejn;
import o.epw;
import o.CollectCheck;
import o.ActivityUtil;
import o.ewm.h;
import o.ewm.j;
import o.ewm.n;
import o.mi;
import o.mt;

public class EditSubTabFragment extends BaseListFragment<BaseListFragmentProtocol> implements c, o.ejh.e {
    private BottomButton ˊ;
    private mi ˋ;
    private String ˎ = "type_view";
    private String ˏ;
    private ejh ॱ;

    class a extends f {
        final /* synthetic */ EditSubTabFragment ˊ;
        int ˎ;

        public a(EditSubTabFragment editSubTabFragment, int i) {
            this.ˊ = editSubTabFragment;
            this.ˎ = i;
        }

        public void ˏ(Rect rect, View view, RecyclerView recyclerView, t tVar) {
            super.ˏ(rect, view, recyclerView, tVar);
            int ˊ = this.ˊ.ˋʽ();
            int ʼ = recyclerView.ʼ(view);
            int ˋˊ = recyclerView.ʻ().ˋˊ();
            ˋˊ = (ˋˊ / ˊ) - (((ˋˊ - (this.ˎ * ˊ)) - this.ˎ) / ˊ);
            rect.left = this.ˎ - ((ʼ % ˊ) * (ˋˊ - this.ˎ));
            rect.top = this.ˎ;
        }
    }

    public static abstract class b implements cks {
        public abstract void ॱ();

        public void enableNetworking() {
            ॱ();
        }

        public void upgrade() {
        }

        public void ˋ() {
        }
    }

    class d extends b {
        final /* synthetic */ EditSubTabFragment ॱ;

        private d(EditSubTabFragment editSubTabFragment) {
            this.ॱ = editSubTabFragment;
        }

        public void ॱ() {
            this.ॱ.ˋʻ();
        }
    }

    class e implements OnClickListener {
        final /* synthetic */ EditSubTabFragment ˏ;

        private e(EditSubTabFragment editSubTabFragment) {
            this.ˏ = editSubTabFragment;
        }

        public void onClick(View view) {
            this.ˏ.ˑॱ();
        }
    }

    public int ߵ() {
        return h.ॱꞌ;
    }

    public void ˏ(Bundle bundle) {
        ॱˋ(true);
        super.ˏ(bundle);
    }

    public View ˋ(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
        this.ˏͺ = ((BaseListFragmentProtocol) ˆ()).ˎ().ˋॱ();
        this.ॱˍ = (ViewGroup) super.ˋ(layoutInflater, viewGroup, bundle);
        ˉॱ();
        ˊʻ();
        ˊʽ();
        return this.ॱˍ;
    }

    private void ˉॱ() {
        BaseListFragmentProtocol baseListFragmentProtocol = (BaseListFragmentProtocol) ˆ();
        if (!(baseListFragmentProtocol == null || baseListFragmentProtocol.ˎ() == null)) {
            this.ˏ = baseListFragmentProtocol.ˎ().ˊ();
        }
        if (CollectCheck.isEmpty(ejn.ˋ().ˋ(this.ˏ))) {
            Logger.e("EditSubTabFragment", "initData: mSubTabItemlList is empty, exception! finish!");
            FragmentActivity ॱˋ = ॱˋ();
            if (ॱˋ != null && !ॱˋ.isFinishing()) {
                ॱˋ.finish();
            }
        }
    }

    private void ˊʻ() {
        this.ˊ = (BottomButton) this.ॱˍ.findViewById(j.ॱꜟ);
        this.ˊ.setOnClickListener(new e());
        if ("type_view".equals(this.ˎ)) {
            this.ˊ.setVisibility(8);
        } else {
            this.ˊ.setVisibility(0);
        }
    }

    private void ˊʽ() {
        RecyclerView recyclerView = (RecyclerView) this.ॱˍ.findViewById(j.ꞌʻ);
        azb.ˏ(recyclerView);
        recyclerView.ॱ(new a(this, ᐝॱ().getDimensionPixelSize(o.ewm.d.ॱˊ)));
        RecyclerView.j gridLayoutManager = new GridLayoutManager(ॱˋ(), ˋʽ());
        recyclerView.setLayoutManager(gridLayoutManager);
        ((mt) recyclerView.ʾ()).ˊ(false);
        this.ॱ = new ejh(ॱˋ(), gridLayoutManager, "type_edit".equals(this.ˎ));
        this.ॱ.ˎ(ejn.ˋ().ˋ(this.ˏ));
        this.ॱ.ˎ((c) this);
        this.ॱ.ˏ((o.ejh.e) this);
        this.ॱ.ˋ(true);
        recyclerView.setAdapter(this.ॱ);
        this.ˋ = new mi(new eji(this.ॱ, this.ˏ));
        this.ˋ.ˏ(recyclerView);
    }

    private int ˋʽ() {
        if (azb.ˎ(ContentManager.getInstant().getContext())) {
            return 6;
        }
        return 3;
    }

    public void ˊ(s sVar) {
        if (this.ˋ != null) {
            this.ˋ.ˏ(sVar);
        }
        this.ˊ.setVisibility(0);
    }

    public void ˎ(String str) {
        if ("type_edit".equals(str)) {
            this.ˎ = "type_edit";
            if (this.ॱ != null) {
                this.ॱ.ˏ(true);
            }
            this.ˊ.setVisibility(0);
            return;
        }
        this.ˎ = "type_view";
        if (this.ॱ != null) {
            this.ॱ.ˏ(false);
        }
        this.ˊ.setVisibility(8);
    }

    private void ˋʻ() {
        ejn.ˋ().ॱ(this.ˏ);
        if (this.ॱ != null) {
            this.ॱ.ˎ(ejn.ˋ().ˋ(this.ˏ));
            this.ॱ.ˊ();
            if (!dof.ˋ(this.ˏ)) {
                ejn.ˋ().ॱ(this.ˏ, dgm.ˎ(ॱˋ()));
            }
        }
    }

    private void ˑॱ() {
        Context ˋ = ContentManager.getInstant().getContext();
        CharSequence string = ˋ.getString(n.ˊʹ);
        CharSequence ॱ = epw.ॱ(ˋ, n.ˉʽ, new Object[0]);
        CharSequence ॱ2 = epw.ॱ(ˋ, n.ˊˈ, new Object[0]);
        cku ˏ = cku.ˏ(ॱˋ(), cku.class, "", string);
        ˏ.ˎ(ॱˋ());
        ˏ.ॱ(-1, ॱ);
        ˏ.ॱ(-2, ॱ2);
        ˏ.ॱ(new d());
    }

    public void ˊ(String str) {
        this.ˎ = str;
    }

    public void ˊ(TabInfo tabInfo, int i) {
        Context ॱˋ = ॱˋ();
        if (!ActivityUtil.isAcitivtyNotValid(ॱˋ)) {
            Intent intent = new Intent();
            intent.putExtra("seleted_tab_postion", i);
            ॱˋ.setResult(10001, intent);
            ॱˋ.finish();
        }
    }
}
